// 导入组件
import Vue from 'vue';
import Router from 'vue-router';
// 登录
import login from '@/views/login';
import forgetPass from '@/views/forgetPass';
// 首页
import index from '@/views/index';
//修改个人信息
import modify from '@/views/modify';


// 启用路由
Vue.use(Router);
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

// 导出路由 
export default new Router({
    routes: [{
        path: '/',
        name: '',
        component: login,
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/modify',
        name: 'modify',
        component: modify,
        meta: {
            requireAuth: true
        }
    }, {
        path: '/login',
        name: '登录',
        component: login,
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/forgetPass',
        name: '忘记密码',
        component: forgetPass,
        hidden: true,
        meta: {
            requireAuth: false
        }
    },
    {
        path: '/index',
        name: '首页',
        component: index,
        iconCls: 'el-icon-tickets',
        children: [{ // 系统管理
            path: '/system_management',
            name: 'system_management',
            component: () => import('@/views/system_management/hinge'),
            children: [
                {
                    path: 'Administrators',
                    name: 'Administrators',
                    component: () => import('@/views/system_management/Administrators'),
                    meta: {
                        requireAuth: true,
                        title:"系统管理 / 基本设置",
                        breadNumber:1,
                        visiable:true,
                        roles:['admin'],
                    }
                }, {
                    path: 'BasicSettings',
                    name: 'BasicSettings',
                    component: () => import('@/views/system_management/BasicSettings'),
                    meta: {
                        requireAuth: true,
                        title:"系统管理 / 管理员",
                        breadNumber:1,
                        visiable:true,
                        roles:['admin'],
                    }
                },
            ]
        }, { // 轮播图列表
            path: '/rotation/index',
            name: 'RotationList',
            component: () => import('@/views/rotation/index'),
            meta: {
                requireAuth: true,
                title:"轮播管理",
                breadNumber:1,
                visiable:true,
                        roles:['admin'],
            }
        }, { // 友情链接列表
            path: '/links/index',
            name: 'LinksList',
            component: () => import('@/views/links/index'),
            meta: {
                requireAuth: true,
                title:"友情链接",
                breadNumber:1,
                visiable:true,
                        roles:['admin'],
            }
        }, { // 栏目管理列表
            path: '/column',
            name: 'column',
            component: () => import('@/views/column/hinge'),
            children: [
                {
                    path: 'index',
                    name: 'columnindex',
                    component: () => import('@/views/column/index'),
                    meta: {
                        requireAuth: true,
                        title:"栏目管理",
                        breadNumber:1,
                        visiable:true,
                        roles:['admin'],
                    }
                }, {
                    path: 'add',
                    name: 'columnadd',
                    component: () => import('@/views/column/add'),
                    meta: {
                        requireAuth: true,
                        title:"新增栏目",
                        breadNumber:2,
                        visiable:true,
                        roles:['admin'],
                    }
                },
            ]
        }, { // 留言面板列表
            path: '/reply_panel/index',
            name: 'ReplyPanelsList',
            component: () => import('@/views/reply_panel/index'),
            meta: {
                requireAuth: true,
                title:"留言面板",
                breadNumber:1,
                visiable:true,
                        roles:['admin'],
            }
        }, 
        { // 文章管理
            path: '/article',
            name: 'article',
            component: () => import('@/views/article/hinge'),
            children: [
                {
                    path: 'index',
                    name: 'articleindex',
                    component: () => import('@/views/article/index'),
                    meta: {
                        requireAuth: true,
                        menuPath: '/article/index',
                        title:"文章管理",
                        breadNumber:1,
                        visiable:true,
                        roles:['admin'],
                    }
                }, {
                    path: 'add',
                    name: 'articleadd',
                    component: () => import('@/views/article/add'),
                    meta: {
                        requireAuth: true,
                        menuPath: '/article/index',
                        title:"新增文章",
                        breadNumber:2,
                        visiable:true,
                        roles:['admin'],
                    }
                },
            ]
        },
        { // 商品管理
            path: '/commodity',
            name: 'commodity',
            component: () => import('@/views/commodity/hinge'),
            children: [
                {
                    path: 'index',
                    name: 'commodityindex',
                    component: () => import('@/views/commodity/index'),
                    meta: {
                        requireAuth: true,
                        menuPath: '/commodity/index',
                        title:"商品管理",
                        breadNumber:1,
                        visiable:true,
                        roles:['admin'],
                    }
                }, {
                    path: 'add',
                    name: 'commodityadd',
                    component: () => import('@/views/commodity/add'),
                    meta: {
                        requireAuth: true,
                        menuPath: '/commodity/index',
                        title:"新增商品",
                        breadNumber:2,
                        visiable:true,
                        roles:['admin'],
                        roles:['admin'],
                    }
                },
            ]
        }]
    }]
})